//
//  ProfileDetail2.m
//  Gradekeeper0.2
//
//  Created by Ben Wu on 11/20/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "ProfileDetail2.h"
#import "Profile.h"
#import "ProfileDetailViewController.h"

@implementation ProfileDetail2

@synthesize profiledetailview;
@synthesize pageNumberLabel;
@synthesize segmentControl;




- (IBAction) detailview:(id)sender {
	selectview = [self.segmentControl selectedSegmentIndex];
	
	//if (selectview==0) {
		
		
		//ProfileDetail2 *pDetail= [[ProfileDetail2 alloc] initWithNibName:@"ProfileDetail2" bundle:nil];
		//self.profiledetail2 = pDetail;
		//[pDetail release];
		//push view
		//ProfileDetailViewController *Detail= [[ProfileDetailViewController alloc] initWithNibName:@"ProfileDetailView" bundle:nil];
		//self.profiledetailview = Detail;
		//[Detail release];
		
	//} 
	
	if (selectview==1) { 
		//push view
		ProfileDetailViewController *Detail= [[ProfileDetailViewController alloc] initWithNibName:@"ProfileDetailView" bundle:nil];
		self.profiledetailview = Detail;
		[Detail release];
		
	}
	[self.navigationController pushViewController:profiledetailview animated:YES];
	//[self.navigationController pushViewController:profiledetailview animated:YES];
	//NSLog(@"%@", semester);
}



// Load the view nib and initialize the pageNumber ivar.
- (id)initWithPageNumber:(int)page {
    if (self = [super initWithNibName:@"ProfileDetailView" bundle:nil]) {
        pageNumber = page;
    }
    return self;
}


//If user chooses to create a new profile
//the view will change to profile creation
- (IBAction) createPressed:(id)sender {
	/*if (self.profiledetailview == nil){
		ProfileDetailViewController *Detail= [[ProfileDetailViewController alloc] initWithNibName:@"ProfileDetailviewController" bundle:nil];
		self.profiledetail2 = pDetail;
		[pDetail release];
	}
	
	[self.navigationController pushViewController:profiledetail2 animated:YES];*/
} //createPressed




- (void)viewDidLoad {
    [super viewDidLoad];
	
	// display an Edit button in the navigation bar for this view controller
	// self.navigationItem.rightBarButtonItem = self.editButtonItem;
	
	// create a custom navigation bar button and set it to say "back"
	UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
	temporaryBarButtonItem.title = @"Back";
	self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
	[temporaryBarButtonItem release];
}



-(void)viewWillAppear:(BOOL)animated {
    Profile *profile = [Profile sharedProfile];
	NSString *tempDisplay = [[NSString alloc] initWithFormat: @"This profile belongs to %@", [profile getUserName]];
	
	nameLabel.text = tempDisplay;
	[tempDisplay release];
	
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
	[nameLabel release];
	[pageNumberLabel release];
    [super dealloc];
}


@end


